package com.itheima;
import java.util.ArrayList;
public class ArrayListDemo5 {
    public static void main(String[] args) {
        //1.创建集合
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student("zhansan",18);
        Student s2 = new Student("lisi",19);
        Student s3 = new Student("wangwu",20);
        //2.添加元素
        list.add(s1);
        list.add(s2);
        list.add(s3);
        //3.遍历集合
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println(stu.getName()+" "+stu.getAge());
            //stu打印的都是地址值 打印对象都是地址值
        }

    }
}
